﻿using FilmBlowingMachine.Common;
using FilmBlowingMachine.ViewModel;
using GalaSoft.MvvmLight.Command;
using GalaSoft.MvvmLight.Messaging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace FilmBlowingMachine
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            this.DataContext = new MainViewModel();

            Messenger.Default.Register<bool>(this, "ExitMainWindow", async arg =>
            {
                if (arg)
                    if (!await Msg.Question("确认退出系统?")) return;
                Environment.Exit(0);
            });
            Messenger.Default.Register<string>(this, "ExpandMenu", arg =>
            {
                if (this.grdLeftMenu.Width < 200)
                    AnimationHelper
                    .CreateWidthChangedAnimation(this.grdLeftMenu, 60, 200, new TimeSpan(0, 0, 0, 0, 250));
                else
                    AnimationHelper
                    .CreateWidthChangedAnimation(this.grdLeftMenu, 200, 60, new TimeSpan(0, 0, 0, 0, 250));
            });
        }

        private void btnMax(object sender, RoutedEventArgs e)
        {
            this.SetWindowSize();
        }

        private void SetWindowSize()
        {
            //if (this.WindowState == WindowState.Normal)
            //    this.WindowState = WindowState.Maximized;
            //else
            //    this.WindowState = WindowState.Normal;
        }

        private void btnClose(object sender, RoutedEventArgs e)
        {
            //Question?
            App.Current.Shutdown();
        }

        private void btnMin(object sender, RoutedEventArgs e)
        {
            this.WindowState = WindowState.Minimized;
        }
        private void btnAbout(object sender, RoutedEventArgs e)
        {
            Link.OpenInBrowser("https://space.bilibili.com/");
        }

        private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {

        }
    }
}
